<?php
/**
 * Created by PhpStorm.
 * User: A510L
 * Date: 2018/1/26
 * Time: 15:28
 */
class Menu_model extends CI_Model
{
    /**
     * User_model constructor.
     * 构造函数，加载数据库配置文件
     */
    public function __construct()
    {
        $this->load->database();
    }

    /**
     * @return mixed
     * 查询全部权限
     */
    public function get_All()
    {
        $query = $this->db->get('menu');
        return $query->result_array();
    }

    /**
     * @param $data
     * 添加菜单
     */
    public function addRole($data){
        $this->db->insert('menu',$data);
    }

    /**
     * @param $id
     * @return mixed
     * 根据ID查询
     */
    public function getMenuById($id){
        $query = $this->db->get_where('menu', array('menu_id' => $id));
        return $query->row_array();
    }

    /**
     * @param $data
     * 按照ID更新
     */
    public function update_menu($data){
        $this->db->update('menu',$data,array('menu_id'=>$data['menu_id']));
    }

    /**
     * @param $id
     * 删除
     */
    public function delete_menu($id){
        $this->db->delete('menu', array('menu_id' => $id));
    }
}